package com.zgc.entity;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
import java.util.stream.Collectors;

@Data
public class TreeSelect implements Serializable {
    private Long id;
    private String label;
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private List<TreeSelect> children;
    public TreeSelect() {
    }
    public TreeSelect(Menu menu) {
        this.id=menu.getId();
        this.label=menu.getName();
        if(null !=menu.getChildren()) {
            this.children =
                    menu.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
        }
    }
}